1. Field of the Invention
The present invention generally relates to a system, method and medium for improving the acquisition time for acquiring a lock and, more particularly, to a system, method and medium for using and/or providing operating system information to acquire a hybrid user/operating system lock.
2. Background Description
FIG. 1, generally at 100, is a conventional computer system that shows the relationship between application programs 101a-n, kernel 105, and hardware 107. Application programs 101a-n can include, for example, conventional word processing, graphic and/or web browser programs, that directly interact with an end user. Application programs 101a-n are executed in user-space 103, and can be referred to as “processes,” or “tasks” when program instructions are executed by the central processing unit (CPU) (not shown).
Kernel 105 includes system call interface 109, kernel subsystems 111, and device drivers 113. Application programs 101a-n communicate with kernel 105 by making a conventional system call. System call interface 109 can receive requests from processes to access hardware 107 such as printers, monitors, storage devices and/or network devices. Kernel 105 can execute these requests via kernel subsystems 111 and device derivers 113 in a conventional manner. Kernel subsystems 111 can also include interrupt handlers to service interrupt requests, a memory management system to manage address spaces, and system services such as networking and interprocess communication (IPC).
When performing, for example, conventional asynchronous input-output (AIO) between application programs 101a-n and kernel 105, application programs 101a-n invoke a system call to kernel 105 to initiate each input-output (I/O). For example, application program 101a-n typically calls a function in a library, such as a C library, that in turn relies on system call interface 109 to instruct kernel 105 to conduct one or more tasks on its behalf. When a system call takes place, an application program 101a-n that makes the call is suspended, and the kernel 105 takes over. The context switch from the application program 101a-n to kernel 105 is costly in terms of performance, as system calls can take, for example, 10 to 1000 times more processing time than a normal processing operation, such as a CPU adding two numbers together.
Conventional techniques of acquiring a lock can be done in user-space 103 where, for example, an application program 101a-n acquires a lock, or by the kernel 105, where the kernel 105 acquires a lock. As used herein, a lock is used to deny access to a given resource, such as a file, memory location, input/output port, and the like, usually to ensure that only one application program 101a-n, and/or process associated therewith, at a time uses the resource.
Although user-space 103 will typically acquire a lock more quickly than kernel 105, user-space 103 does not know, for example, the overall state of the various processes and threads being executed and/or managed by kernel 105. On the other hand, although kernel 105 knows the overall state of the various processes and threads being executed and/or managed by kernel 105, an application program 101a-n call into kernel 105, as indicated above, typically takes at least an order of magnitude more processing time to acquire a lock than if application program 101a-n requests a lock and acquires the lock without making a call to kernel 105. If application program 101a, requests a lock and does not acquire the lock, application program 101a, short of making a call to kernel 105, can keep attempting to acquire the lock. However, using known techniques, application program 101a cannot tell if it cannot obtain the lock because, for example, another program (e.g., application program 101c) is being executed on (or by) the same processor has the lock, or because another program (e.g., application program 101d) being executed on (or by) another processor in a multiprocessor system has the lock.
One conventional technique attempts to reduce the number of system calls by having application program 101a-n first attempt to acquire a lock in user-space 103. If the lock, after one or more attempts, is not acquired in user-space 103, application program 101a-n then makes a call to kernel 105. However, in using this technique, kernel 105 does not make information available to a memory space that is shared by application program 101a-n and kernel 105, so that application program 101a-n can use the information to determine the state and/or status of various processes, tasks, etc. being processed by, or waiting to be processed by, kernel 105.